//
//  MyFindWinBaoJiaViewController.m
//  CarTown
//
//  Created by xionghao on 15/8/29.
//  Copyright (c) 2015年 熊浩. All rights reserved.
//

#import "MyFindWinBaoJiaViewController.h"
#import "NoramlCellMode.h"
#import "NoramlTableViewCell.h"
#import "HuiyingHeaderTableViewCell.h"
#import "GridTableViewCell.h"
#import "GirdTitleTableViewCell.h"
#import "HuiyingTitleTableViewCell.h"
#import "XQModel.h"
#import "GridCellModel.h"
#import "GridTtitleMode.h"
#import "HyHeaderMode.h"
#import "HyOhterTitleMode.h"
#import "BlueDetailMode.h"
#import "PeizhiMode.h"
#import "PeiZhiTableViewCell.h"
#import "BaojiaTitleTableViewCell.h"
#import "MyWinTitleModel.h"
#import "MyFindCummerTitleCell.h"
@interface MyFindWinBaoJiaViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UIButton *callbtn;
@property (weak, nonatomic) IBOutlet UIView *sendmessage;
@property (weak, nonatomic) IBOutlet UIButton *okbtn;
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic,strong) NSMutableArray *sectionArray;
@end

@implementation MyFindWinBaoJiaViewController
+(instancetype)viewController{
    MyFindWinBaoJiaViewController *qbtvc=[[MyFindWinBaoJiaViewController alloc]initWithNibName:NSStringFromClass([self class]) bundle:nil];
    return qbtvc;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.backgroundColor=bgGarycolor;
    self.tableView.contentInset=UIEdgeInsetsMake(0, 0, 64, 0);
    [self setupdata];
    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        
        [self.tableView setSeparatorInset:UIEdgeInsetsZero];
        
    }
    
    if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
        
        [self.tableView setLayoutMargins:UIEdgeInsetsZero];
        
    }
    // Do any additional setup after loading the view from its nib.
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        
        [cell setSeparatorInset:UIEdgeInsetsZero];
        
    }
    
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        
        [cell setLayoutMargins:UIEdgeInsetsZero];
        
    }
    
    
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section==0) {
        return 0.1;
    }else{
        return 16;
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0;
}
-(NSMutableArray *)sectionArray{
    if ( _sectionArray==nil) {
        _sectionArray=[NSMutableArray array];
    }
    return  _sectionArray;
}
-(void)setupdata{
    
    MyWinTitleModel *title=[[MyWinTitleModel alloc]init];
    
    HyHeaderMode *header=[[HyHeaderMode alloc]init];
    header.rowheight=60;
    GridTtitleMode *gridtitle=[[GridTtitleMode alloc]init];
    
    GridCellModel *leixing=[[GridCellModel alloc]init];
    leixing.title=@"车源类型";
    leixing.detail=@"加版";
    leixing.huiyingstr=@"加版";
    GridCellModel *waiguan=[[GridCellModel alloc]init];
    waiguan.title=@"外观颜色";
    waiguan.detail=@"黑";
    waiguan.huiyingstr=@"黑";
    GridCellModel *neishi=[[GridCellModel alloc]init];
    neishi.title=@"内饰颜色";
    neishi.detail=@"白";
    neishi.huiyingstr=@"白";
    GridCellModel *kuning=[[GridCellModel alloc]init];
    kuning.title=@"库龄要求";
    kuning.detail=@"3个月";
    kuning.huiyingstr=@"3个月";
    GridCellModel *paifang=[[GridCellModel alloc]init];
    paifang.title=@"排放要求";
    paifang.detail=@"国四";
    paifang.huiyingstr=@"国四";
    GridCellModel *jiaohuo=[[GridCellModel alloc]init];
    jiaohuo.title=@"交货日期";
    jiaohuo.detail=@"3天";
    jiaohuo.huiyingstr=@"3天";
    GridCellModel *didian=[[GridCellModel alloc]init];
    didian.title=@"交货地点";
    didian.detail=@"不限";
    didian.huiyingstr=@"不限";
    GridCellModel *fangshi=[[GridCellModel alloc]init];
    fangshi.title=@"交车方式";
    fangshi.detail=@"卖家发车";
    fangshi.huiyingstr=@"卖家发车";
    GridCellModel *yixiang=[[GridCellModel alloc]init];
    yixiang.title=@"意向价";
    yixiang.detail=@"70万";
    yixiang.huiyingstr=@"70万";
    
    HyOhterTitleMode *othermode=[[HyOhterTitleMode alloc]init];
    BlueDetailMode *shouxu=[[BlueDetailMode alloc]init];
    shouxu.title=@"手续";
    shouxu.detail=@"关单";
    
    BlueDetailMode *kuwei=[[BlueDetailMode alloc]init];
    kuwei.title=@"库位";
    kuwei.detail=@"南区";
    BlueDetailMode *xingzhi=[[BlueDetailMode alloc]init];
    xingzhi.title=@"车源性质";
    xingzhi.detail=@"自店";
    
    PeizhiMode *mode=[[PeizhiMode alloc]init];
    mode.title=@"备注";
    
    NSArray *array=@[title,header,gridtitle,leixing,waiguan,neishi,kuning,paifang,jiaohuo,didian,fangshi,yixiang,othermode,shouxu,kuwei,xingzhi,mode];
    [self.sectionArray addObject:array];
    
    XQModel *xuzhimode=[[XQModel alloc]init];
    xuzhimode.img=@"qb_y_ico";
    xuzhimode.title=@"招投标须知";
    xuzhimode.color=UIColorWithRGB(251, 75, 55);
    [self.sectionArray addObject:@[xuzhimode]];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return self.sectionArray.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
    // Return the number of rows in the section.
    NSArray *array=self.sectionArray[section];
    return array.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSArray *array=self.sectionArray[indexPath.section];
    NoramlCellMode *mode=array[indexPath.row];
    if (mode.rowheight) {
        return mode.rowheight;
    }else{
        return 40;
    }
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSArray *array=self.sectionArray[indexPath.section];
    NoramlCellMode *mode=array[indexPath.row];
    if ([mode isKindOfClass:[HyHeaderMode class]]) {
        HuiyingHeaderTableViewCell *cell=[HuiyingHeaderTableViewCell cellWithTableView:tableView];
        return cell;
    }else if ([mode isKindOfClass:[MyWinTitleModel class]]){
        MyFindCummerTitleCell *cell=[MyFindCummerTitleCell cellWithTableView:tableView];
        return cell;
    }
    
    else if([mode isKindOfClass:[HyOhterTitleMode class]])
    {
        HuiyingTitleTableViewCell *title=[HuiyingTitleTableViewCell cellWithTableView:tableView];
        return title;
    }else if ([mode isKindOfClass:[GridTtitleMode class]]){
        GirdTitleTableViewCell *cell=[GirdTitleTableViewCell cellWithTableView:tableView];
        return cell;
    }else if ([mode isKindOfClass:[XQModel class]]){
        
        XQModel *xq=mode;
        BaojiaTitleTableViewCell *cell=[BaojiaTitleTableViewCell cellWithTableView:tableView];
        cell.icon.image=[UIImage imageNamed:xq.img];
        cell.title.text=xq.title;
        cell.title.textColor=xq.color;
        return cell;
    }
    
    else if ([mode isKindOfClass:[GridCellModel class]]){
        GridTableViewCell *cell=[GridTableViewCell cellWithTableView:tableView];
        GridCellModel *gridmode=mode;
        
        cell.title.text=gridmode.title;
        cell.zhaobiaotext.text=gridmode.detail;
        cell.huiyingtext.text=gridmode.huiyingstr;
        return cell;
    }else if ([mode isKindOfClass:[PeizhiMode class]]){
        PeizhiMode *peizhi=mode;
        if (peizhi.longdetail) {
            PeiZhiTableViewCell *cell=[PeiZhiTableViewCell cell];
            return cell;
        }else{
            NoramlTableViewCell *cell=[NoramlTableViewCell cellWithTableView:tableView];
            cell.textLabel.text=mode.title;
            cell.detailTextLabel.textColor=textnormalGary;
            cell.detailTextLabel.text=@"无";
            return cell;
        }
    }else{
        NoramlTableViewCell *cell=[NoramlTableViewCell cellWithTableView:tableView];
        cell.textLabel.text=mode.title;
        cell.detailTextLabel.text=mode.detail;
        cell.detailTextLabel.textColor=tintblue;
        return cell;
    }
    
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
